<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="88px">
      <el-form-item label="所属项目" prop="projectId">
        <el-select v-model="queryParams.projectId" filterable clearable placeholder="请选择所属项目">
          <el-option
            v-for="item1 in projectList"
            :key="item1.id"
            :label="item1.name"
            :value="item1.id">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="list">
      <el-table-column label="项目名称" align="center" prop="projectName" />
      <!-- <el-table-column label="厂商" align="center" prop="supplierName"  /> -->
      <el-table-column label="总数" align="center" prop="totalNum" />
      <el-table-column label="已激活" align="center" prop="activationNum"/>
      <el-table-column label="已解绑" align="center" prop="unboundNum"/>
      <el-table-column label="未绑定" align="center" prop="notactiveNum" />
      <el-table-column label="报废" align="center" prop="scrapNum" />
      <el-table-column label="剩余库存" align="center" prop="remainingNum" />
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { getList, } from "@/api/parking/qrcodeStatist";
import { listAllFaParkProject,} from "@/api/config/projectPushManage";
export default {
  name: "QrcodeStatist",
  dicts: ['project_push_type'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 字典表格数据
      list: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        projectId: undefined,
        devicetype:13,
      },
      projectList:[],//项目数据
    };
  },
  created() {
    this.listAllFaParkProject()
    this.getList();
  },
  methods: {
    async listAllFaParkProject(){//查询返回所有项目列表
      let res = await listAllFaParkProject()
      let data = res.data || []
      this.projectList = data
    },
    /** 查询字典类型列表 */
    getList() {
      this.loading = true;
      getList(this.queryParams).then(response => {
          this.list = response.rows || [];
          this.total = response.total || 0;
          this.loading = false;
        }
      );
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  }
};
</script>
